﻿var keyValue = request('keyValue');

var acceptClick;
var bootstrap = function ($, learun) {
    "use strict";

    var Extension = "";
    var page = {
        init: function () {
            page.initControl();
        },
        //初始化控件
        initControl: function () {
            console.log(keyValue);
            //获取表单
            if (!!keyValue) {
                $.lrSetForm(config.base_server() + 'fileinfos/findById?id=' + keyValue, function (data) {//
                    $('#form').lrSetFormData(data);
                    Extension = data.ext;
                    var name = data.name.replace(Extension, '');
                    $("#name").val(name).focus().select();
                });
            }
        }
    };
    //保存表单
    acceptClick = function (callBack) {
        if (!$('#form').lrValidform()) {
            return false;
        }
        var postData = $("#form").lrGetFormData(keyValue);
        postData["keyValue"] = keyValue;
        postData["name"] = $("#name").val() + Extension;

        $.lrSaveForm(config.base_server() + 'fileinfos/saveOrUpdate?access_token=' + config.getToken().access_token + '&keyValue=' + keyValue, JSON.stringify(postData), function (res) {
            // 保存成功后才回调
            if (!!callBack) {
                callBack();
            }
        });
    }
    page.init();
}


